package com.wuzuqing.android.eightdiagrams.model;

import java.util.ArrayList;
import java.util.List;

public class QiMenDunJiaItem {


    private String gua;
    private int gongNum;

    private String shen = "";
    private String men = "";
    private String originMen = "";
    private String xing = "";
    private String originXing = "";
    private String tianPanGan = "";
    private String diPanGan = "";
    private String diPanCangGan = "";
    private String diPanZhi = "";

    private String huanHang;
    //  private static final long FLAG_A = 1L << 0; // 0001
    //    private static final long FLAG_B = 1L << 1; // 0010
    //    private static final long FLAG_C = 1L << 2; // 0100
    public static final long FLAG_ZHIFU = 1L;//值符
    public static final long FLAG_RIGAN = 1L << 1; //日干
    public static final long FLAG_SHIGAN = 1L << 2; //时干
    public static final long FLAG_YIMA = 1L << 3;//驿马
    public static final long FLAG_KONGWANG = 1L << 4;//空亡
    public static final long FLAG_JIXING = 1L << 5;//击邢
    public static final long FLAG_POGONG = 1L << 6;//迫宫
    public static final long FLAG_RUMU = 1L << 7;//入墓
    public static final long FLAG_ZhiShi = 1L << 8;//入墓
    private String flagStr = "";

    private List<String> juInfo;

    private long flagVal_1;

    // 设置位标记
    public void setFlag(long flag) {
        flagVal_1 = flagVal_1 | flag;
    }

    // 清除位标记
    public void clearFlag(long flag) {
        flagVal_1 = flagVal_1 & ~flag;
    }

    // 检查是否设置了位标记
    public boolean isFlagSet(long flag) {
        return (flagVal_1 & flag) == flag;
    }

    public QiMenDunJiaItem(String gua, int gongNum, String diPanZhi, String huanHang) {
        this.gua = gua;
        this.gongNum = gongNum;
        this.huanHang = huanHang;
        this.diPanZhi = diPanZhi;
    }

    public QiMenDunJiaItem setMenXing(String originMen, String originXing) {
        this.originMen = originMen;
        this.originXing = originXing;
        return this;
    }

    public QiMenDunJiaItem() {
    }

    public String getGua() {
        return gua;
    }

    public void setGua(String gua) {
        this.gua = gua;
    }

    public int getGongNum() {
        return gongNum;
    }

    public void setGongNum(int gongNum) {
        this.gongNum = gongNum;
    }

    public String getShen() {
        return shen;
    }

    public void setShen(String shen) {
        this.shen = shen;
    }

    public String getMen() {
        return men;
    }

    public void setMen(String men) {
        this.men = men;
    }

    public String getOriginMen() {
        return originMen;
    }

    public void setOriginMen(String originMen) {
        this.originMen = originMen;
    }

    public String getXing() {
        return xing;
    }

    public void setJiXing(String jiXing) {
        this.xing = jiXing;
    }

    public String getOriginXing() {
        return originXing;
    }

    public void setOriginXing(String originXing) {
        this.originXing = originXing;
    }

    public String getTianPanGan() {
        return tianPanGan;
    }

    public void setTianPanGan(String tianPanGan) {
        this.tianPanGan = tianPanGan;
    }

    public String getDiPanGan() {
        return diPanGan;
    }

    public void setDiPanGan(String diPanGan) {
        this.diPanGan = diPanGan + this.diPanGan;
    }

    public void setAppendDiPanGan(String diPanGan) {
        this.diPanGan = this.diPanGan + diPanGan;
    }

    public String getDiPanZhi() {
        return diPanZhi;
    }

    public void setDiPanZhi(String diPanZhi) {
        this.diPanZhi = diPanZhi;
    }

    public String getHuanHang() {
        return huanHang;
    }

    public void setHuanHang(String huanHang) {
        this.huanHang = huanHang;
    }

    public String getDiPanCangGan() {
        return diPanCangGan;
    }

    public void setDiPanCangGan(String diPanCangGan) {
        this.diPanCangGan = diPanCangGan;
    }

    public boolean isZhiFu() {
        return isFlagSet(FLAG_ZHIFU);
    }

    public void setZhiFu(boolean zhiFu) {
        if (zhiFu){
            setFlag(FLAG_ZHIFU);
        }
    }

    public boolean isZhiShi() {
        return isFlagSet(FLAG_ZhiShi);
    }
    public void setZhiShi(boolean zhiShi) {
        if (zhiShi){
            setFlag(FLAG_ZhiShi);
        }
    }

    public boolean isRiGan() {
        return isFlagSet(FLAG_RIGAN);
    }

    public void setRiGan(boolean riGan) {
        if (riGan){
            setFlag(FLAG_RIGAN);
        }
    }

    public boolean isShiGan() {
        return isFlagSet(FLAG_SHIGAN);
    }

    public void setShiGan(boolean shiGan) {
        if (shiGan){
            setFlag(FLAG_SHIGAN);
        }
    }

    public boolean isYiMa() {
        return isFlagSet(FLAG_YIMA);
    }

    public void setYiMa(boolean yiMa) {
        if (yiMa){
            setFlag(FLAG_YIMA);
        }
    }

    public boolean isKongWang() {
        return isFlagSet(FLAG_KONGWANG);
    }

    public void setKongWang(boolean kongWang) {
        if (kongWang){
            setFlag(FLAG_KONGWANG);
        }
    }

    public String getFlagStr() {
        return flagStr;
    }

    public void setFlagStr(String flagStr) {
        this.flagStr = flagStr;
    }

    public boolean isJiXing() {
        return isFlagSet(FLAG_JIXING);
    }

    public void setJiXing(boolean jiXing) {
        if (jiXing){
            setFlag(FLAG_JIXING);
        }
    }


    public boolean isPoGong() {
        return isFlagSet(FLAG_POGONG);
    }

    public void setPoGong(boolean poGong) {
        if (poGong){
            setFlag(FLAG_POGONG);
        }
    }

    public boolean isRuMu() {
        return isFlagSet(FLAG_RUMU);
    }

    public void setRuMu(boolean ruMu) {
        if (ruMu){
            setFlag(FLAG_RUMU);
        }
    }

    public List<String> getTianDiPan() {
        List<String> list = new ArrayList<>();
        for (char tian : tianPanGan.toCharArray()) {
            for (char di : diPanGan.toCharArray()) {
                list.add(tian + "" + di);
            }
        }
        return list;
    }

    public void setJuInfo(List<String> juInfo) {
        this.juInfo = juInfo;
    }

    public List<String> getJuInfo() {
        return juInfo;
    }
}